<template>
  <div class="clear">
    <div id="header-index" class="flex">
      <div class="h-50 header-left">
        <!-- 展开/关闭菜单 -->
        <i
          @click="changeMenu"
          :class="menuIsOpen ? '' : 'rotate'"
          class="el-icon-s-fold mr-20"
        />
        <!-- 路径 -->
        <myPath />
      </div>
      <div class="h-50">
        <!-- 退出 -->
        <i @click="toLogin" class="el-icon-switch-button"></i>
      </div>
    </div>
    <history />
  </div>
</template>

<script>
import myPath from "./path";
import history from "./history";
export default {
  components: {
    myPath,
    history
  },
  data() {
    return {
      menuIsOpen: true
    };
  },
  watch: {
    // 展开/收起菜单
    menuIsOpen(newValue) {
      const elMenu = document.getElementById("myMenu");
      const frameRight = document.getElementById("frame-right");
      if (newValue) {
        elMenu.classList.remove("w-0");
        frameRight.classList.remove("frame-right-full");
      } else {
        elMenu.classList.add("w-0");
        frameRight.classList.add("frame-right-full");
      }
    }
  },
  methods: {
    // 回到登录
    toLogin() {
      this.$store.commit("common/TO_LOGIN");
    },
    // 收起/展开菜单
    changeMenu() {
      this.menuIsOpen = !this.menuIsOpen;
    }
  }
};
</script>

<style lang="scss">
#header-index {
  .el-breadcrumb__item {
    line-height: 50px;
  }
  .el-breadcrumb__separator {
    margin: 0 5px;
  }
}
</style>
<style lang="scss" scoped>
#header-index {
  height: 50px;
  line-height: 50px;
  box-shadow: 0 1px 2px $default-shadow;
  box-sizing: border-box;
  padding: 0 15px;
}
i {
  font-size: $font-24;
  line-height: 50px;
  cursor: pointer;
}
.rotate {
  transform: rotateZ(180deg);
}
.el-icon-s-fold {
  float: left;
}
.currentRoure {
  color: $placeholder;
  line-height: 50px;
  float: left;
  font-size: $font-14;
  margin-left: 20px;
}
.header-left {
  width: 50%;
}
</style>
